﻿using System; 
using Besture.Bll;
using Besture.Common;
using Besture.Common.Helper;
using Besture.Model;
using Besture.UI.Common;

namespace Besture.UI.Portal.DealerRegister
{
    public partial class DealerRegisterList : System.Web.UI.Page
    {
        
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["registerPhoneCode"] = "";//默认值
        }  

        /// <summary>
        /// 注册功能
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSaveClick(object sender, EventArgs e)
        {

            if (cbClause.Checked ==false)
            {
                FunHelper.Alert("请选择翔盛服务条款");
                return ;
            }

            var identityId = -1;
            var dac = new UserBaseDac();
            var baseDac = new BaseDac<UserBaseModel>();
            //添加  
            UserBaseModel model = new UserBaseModel
            {
                LoginName = txtLoginName.Text.Trim(),
                LoginPwd = StringHelper.GetMD5(newpwd.Value.Trim()),
                Phone = txtPhone.Text.Trim(),
                Email = txtEmail.Text.Trim(),
                AreaCode = txtAreaCode.Text.Trim(),
                Tel = txtTel.Text.Trim(),
                TelExt = txtTelExt.Text.Trim(),
                CompanyName = txtCompanyName.Text.Trim(),
                Representative = txtRepresentative.Text.Trim(),
                Address = txtAddress.Text.Trim(),
                Birthday = DateTime.Now,
                StatusTime = DateTime.Now,
                UserType = Constants.USER_TYPE_DISTRIBUTOR,
                CheckStatus = Constants.USER_CHECK_CHECKING
            };

            //加载添加基本数据
            baseDac.LoadAddBaseModel(model);
            identityId = dac.Add(model);

            if (identityId > 0)
                FunHelper.Alert("保存成功", "DealerReviewList.aspx");
            else
                FunHelper.Alert("保存失败");
        }

    }
}